import java.util.Collection;
import java.util.Set;
import java.util.TreeMap;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2024-04-08
 * Time: 23:09
 */
public class TestMap {
    public static void main(String[] args) {
        Map <String,Integer> map = new TreeMap<>();
        map.put("hello",7);
        map.put("bit",5);
        map.put("123",6);
        Integer val = map.get("hello");
        System.out.println(val);
        System.out.println(map.getOrDefault("aaaa", 99));
        Set<String> set = map.keySet();
        System.out.println(set);
       /* for (String ret: set) {
            System.out.println(ret);
        }*/

        Collection<Integer> collection = map.values();
        System.out.println(collection);


        Set<Map.Entry<String,Integer>> set1 = map.entrySet();
       /* System.out.println(set1);*/
        for (Map.Entry<String,Integer> entry: set1) {
            System.out.println("key: "+entry.getKey() +"  "+"value: "+entry.getValue());
        }
    }
}
